
const { request } = require('../../services/request')
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    selected: Number
  },
 
  /**
   * 组件的初始数据
   */
  data: {
    selected: 0,
    color: "#858585",
    selectedColor: "#65B0B4",
    navbarBg: '/assets/images/navbar-tab.png',
    tongueImg: '../../assets/images/tongue.png',
    listTab: [
      {
        pagePath: "/pages/home/index",
        text: "首页",
        selectedIconPath: "../../assets/images/home-selected.png",
        iconPath: "../../assets/images/home-unselected.png"
      },
      {
        pagePath: "/pages/my/index",
        text: "我的",
        selectedIconPath: "../../assets/images/my-selected.png",
        iconPath: "../../assets/images/my-unselected.png"
      }
    ],
    selectingUser:false,
  },

  /**
   * 组件的方法列表
   */
  methods: {
    switchTab(e) {
      const data = e.currentTarget.dataset;
      const url = data.path;
      wx.switchTab({ url });
      // this.setData({
      //  selected: data.index
      // })
    },
    handleGoTongue() {
      // this.triggerEvent('goTongue') 
      // this.setData({
      //   selectingUser:true
      // })
      // request('POST', "/applet/answer/user/list",).then(res => {
      //   if (res.data.length) {
      //     let answeUserId = res.data[0].answeUserId
      //     const { userId } = JSON.parse(wx.getStorageSync('userInfo')) 
      //     wx.navigateTo({
      //         url: `/pages/camera/index?menuId=${1}&userId=${userId}&answeUserId=${answeUserId}`,
      //     })
      //   } else {
      //     wx.navigateTo({
      //       url: '/pages/user-list/index',
      //     })
      //   }
      // }).catch()
      const userId=JSON.parse(wx.getStorageSync('userInfo')).userId
          wx.navigateTo({
            url: `/pages/channel/index?title=智能舌诊&menuId=1&userId=${userId}`
          })
    },
    handelSelectUser(){
      console.log('select user in custom',e)
      const { answeUserId, userId } = e.detail
      wx.navigateTo({
        url: `/pages/channel/index?title=智能舌诊&menuId=1&userId=${userId}&answeUserId=${answeUserId}`,
      })
    },
    hideUserSelect(){
      this.setData({
        selectingUser:false
      })
    }
  },
  lifetimes: {
    attached: () => {
      // console.log(wx.router.getRouteContext())
    }
  }
})